package com.starlinkdt.common.storage;

import com.starlinkdt.common.storage.impl.*;
import com.starlinkdt.common.utils.spring.SpringUtils;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.Map;

/**
 * @author system
 */
@Component
public class StorageFactory {
    private static final Map<String, StorageInterface> STORAGE_MAP = new HashMap<>();

    @PostConstruct
    public void init() {
        STORAGE_MAP.put(StorageEnum.AliYunOss.getCode(), SpringUtils.getBean(AliYunOssImpl.class));
        STORAGE_MAP.put(StorageEnum.HuaweiCloudObs.getCode(), SpringUtils.getBean(HuaweiCloudObsImpl.class));
        STORAGE_MAP.put(StorageEnum.CtYunZos.getCode(), SpringUtils.getBean(CtYunZosImpl.class));
        STORAGE_MAP.put(StorageEnum.NsccTjOss.getCode(), SpringUtils.getBean(NsccTjOssImpl.class));
        STORAGE_MAP.put(StorageEnum.Minio.getCode(), SpringUtils.getBean(MinioImpl.class));
    }

    public static StorageInterface generate(StorageEnum storageEnum) {
        return STORAGE_MAP.get(storageEnum.getCode());
    }

}
